﻿@model IEnumerable<VehicleManagement.Models.AddGas>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="../../Scripts/deleteFunction.js" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/SetPagingScript.js")" type="text/javascript"></script>
<script type="text/javascript">

    $(function () {
        if ($.query.get("Page") != "") {
            $("#Page").val($.query.get("Page"));
        }
        else {
            $("#Page").val(1);
        }

        if ($.query.get("Car_num") != "" && !$.query.get("Car_num")) {
            $("input[name='Car_num']").val($.query.get("Car_num"));
        }

        if ($.query.get("Gas_Name") != "" && !$.query.get("Gas_Name")) {
            $("input[name='Gas_Name']").val($.query.get("Gas_Name"));
        }

        if ($.query.get("Approval") != "" && !$.query.get("Approval")) {
            $("input[name='Approval']").val($.query.get("Approval"));
        }

        $.get("/AddGas/GetPagingInfo",
            {
                Car_num: $("input[name='Car_num']").val(),
                Gas_Name: $("input[name='Gas_Name']").val(),
                Approval: $("input[name='Approval']").val(),
                Page: $("#Page").val()
            },
            function (data) {
                $("#TotalItems").text(data.TotalItems);
                $("#ItemsPerPage").text(data.ItemsPerPage);
                $("#TotalPages").text(data.TotalPages);
                $("#CurrentPage").text($("#Page").val());
            }
        );
        SetPagingOperation();
    });
    function DeleteAddGas(id) {
        if (confirm("你确认删除这条加油信息吗?")) {
            $.post("/AddGas/DeleteAddGas", "id=" + id, function (ret) {
                if (ret.Result == "true") {
                    alert(ret.Message);
                    window.location.reload();
                }
                else {
                    alert(ret.Message);
                }
            }, "json");
        }
    }
</script>
<p>
    @Html.ActionLink("添加加油信息", "Create")
</p>
<div>
    <div>
        条件筛选：
    </div>
    @using (Html.BeginForm("Index", "AddGas", FormMethod.Get, new { id = "SearchForm" }))
    {
        @Html.Hidden("Page");
        <div>
            <input id="key1" name="Car_num" type="text" value="车牌号" />
        </div>
        <div>
            <input id="key2" name="Gas_Name" type="text" value="燃油名称" />
        </div>
        <div>
            <select name="Approval">
                <option selected="selected">申请状态</option>
                <option>未审批</option>
                <option>已审批</option>
            </select>
        </div>
        <div>
            <input name="key" type="text" value="模糊查找" /><input type="submit" value="点击查询" />
        </div>
    }
    <div class="clear">
        s
    </div>
</div>
<table>
    <tr>
        <th>
            Car_num
        </th>
        <th>
            Driver_name
        </th>
        <th>
            Gas_Date
        </th>
        <th>
            Cost
        </th>
        <th>
            Approval
        </th>
        <th>
            GasSta_Name
        </th>
        <th>
            Remark
        </th>
    </tr>
    @foreach (var item in Model)
    {
   
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Car_num)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Driver_name)
            </td>
            <td>
                @String.Format("{0:yyyy.MM.dd}", item.Gas_Date)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Cost)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Approval)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.GasSta_Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Remark)
            </td>
            <td>
                @Html.ActionLink("编辑", "Edit", new { id = item.AddGasID }) |
                @Html.ActionLink("详细", "Details", new { id = item.AddGasID }) | <a href="javascript:void(0)" onclick="DeleteAddGas(@item.AddGasID)">
                    删除</a>
            </td>
            <td>
            </td>
        </tr>
    }
</table>
<div>
    共<span id="TotalItems"></span>条记录， 每页显示<span id="ItemsPerPage"></span>条， 共<span id="TotalPages"></span>页，
    当前第<span id="CurrentPage"></span>页 <a id="FirstPage" href="javascript:void(0)">首页</a>
    <a id="PrevPage" href="javascript:void(0)">上一页</a> <a id="NextPage" href="javascript:void(0)">
        下一页</a> <a id="LastPage" href="javascript:void(0)">末页</a> <span>跳转到</span>
    <input type="text" id="PageToGo" />
    <input type="button" id="GoToPage" value="Go" />
</div>
